#ifndef ICESAILING_H
#define ICESAILING_H
#include "tools/Wings.h"
#include "tools/Reader.h"
#include "tools/Gadget.h"
#include "tools/Diary.h"
#include "solar/beacon/Field.h"
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QStringList>
#include <QProcess>
#include <QDir>
#include <QDateTime>
#include <QMap>
#include <QCryptographicHash>
#include <QCoreApplication>
#include <QStandardPaths>

class DepotMang{

public:
    DepotMang();

protected:
    QString SYSPATH = QCoreApplication::applicationDirPath();
    QStringList RUNNINGENV;

    /*------DATE-TIME------*/
    QDateTime CURDATE = QDateTime::currentDateTime();
    QString TIMEFORMAT = "yyyy-MM-dd-hhmmss";
    QString FORMATDATE = QDateTime::currentDateTime().toString(TIMEFORMAT);

    /*------DATAWH------*/
    QString DATA_WAREHOUSE = "db";
        /*------RL-INFO------*/
    QString RLNAME = "config.ini";
    QString RLPATH;

        /*------db-info------*/
    QString DBNAME;
    QString DBKEY = "CONFIGURATION-APPLICTION";
    QString DBPATH;

    /*------LOG-INFO------*/
    QString MAINLOGDIRECTORY = "main-diary";
    QString LOGNAME = "diary-" + FORMATDATE + ".log";
    QString LOGPATH;

    /*------qss------*/
    QStringList QssList = {":/QSS/bench/Qssdesign.qss"};

    /*------nwresource-------*/
    QString MEDIA_FDNAME = "media-resoutcs";
    QString MEDIAMS_FDNAME = "ms";
    QString MEDIAMV_FDNAME = "mv";
    QString RESOURCE_MSPATH;
    QString RESOURCE_MVPATH;
    /*------appliction folder------*/
    QString DEPOTFD;

    /*------lc-info------*/
    QString LCUSERNAME;

    /*------sql-object------*/
    QSqlDatabase *DATABASE;
    QSqlQuery *QUERY;

    /*------serial log------*/
    QString SERIAL_FDNAME = "serial-diary";
    QString SERIAL_FDPATH;

    /*------qrcode------*/
    QString QRCODE_FDNAME = "qrcode";
    QString QRCODE_FDPATH;

    /*------cfg-check------*/
    bool MD5CHECK;
    bool CTCHECK;

    /*------map-info------*/
    QMap<QString, QString> RLUPDTINFP;
    QMap<QString, QMap<QString, QString>> RGLRLSMAP;
    QMap<QString, QPair<QString, QString>> LCDBMAP;
    QMap<QString, QString> QSSMAP;

    /*------bsc-ininfo------*/
    QStringList _INI_REGISTER_;
    QStringList _INI_LOSSKEY_;

    /*------regularexp------*/
    QString RLREG = "^\\[(.*)\\]";
    QString QSSREG = "^[#|@|*|^|#|$]+([a-z_0-9A-Z]+)[\\s|\\W]*";

    QString _HEADERS_ = "user-agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
                        "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51";

    QString _INIFILE_ = ""
    ";<<Customize Arguments>>"
    ";in the case of multi data can to be line feed or comma partition\n"
    ";the unit of time is msec for thereinto\n"
"\n"
    "[MD5]\n"
    "MD5=CryptCode\n"
"\n"
    "[MANG];Manage Door\n"
    "WindownGeometryW=566\n"
    "WindownGeometryH=350\n"
"\n"
    "[TOOL];AnalySis Tool\n"
    "WindownGeometryW=1020\n"
    "WindownGeometryH=630\n"
    "DefaultAnalysisRate=2\n"
    "CommonlyFolder=Follow\n"
    "ToolType=1\n"
"\n"
    "[CMR];QRcode Tool\n"
    "ConstomMakeCharE=cameraID:unknown P:unknown\n"
    "ConstomMakeChar=cameraID:unknown\n"
    "QrcodeForeColor=green\n"
    "QrcodeBackColor=whitesmoke\n"
    "QrcodeBorderXP=1\n"
    "QrcodeSizeRtXP=6\n"
    "QRcodeSavePath=default\n"
"\n"
    "[MSC];IC Music\n"
    "WindownGeometryW=1020\n"
    "WindownGeometryH=630\n"
    "CurrentSwitchOverType=0\n"
    "CommonlyFolder=Follow\n"
    "DriverLocalDishLoop=True\n"
    "CommonlyDriverPath = Desktop\n"
    "DriverMatchingChar=chromedriver,msedgedriver,geckodriver\n"
    "DriverMatchingCharModel=True\n"
    "NetworkVisitRangeNum=10\n"
"\n"
    "[VSTADDRE];Visit Address\n"
    "XmsjOfficAddres=http://www.xmsj.org/?\n"
    "MyfreeOfficAddres=http://tools.liumingye.cn/music_old/?\n"
    "MyfreeSupplement=#/search/M/song/%1\n"
    "ChromeOfficAddres=https:/chromedriver.chromium.org/downloads\n"
    "ChromeGetAddres=https:/chromedriver.storage.googleapis.com/%1/chromedriver_win32.zip\n"
    "EdgeOfficAddres=https:/developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/\n"
    "EdgeGetAddres=https:/msedgedriver.azureedge.net/%1/edgedriver_win64.zip\n"
    "Lrc_Visit=https:/www.93lrc.com/search?keyword=%1\n"
    "Lrc_Get=https:/www.93lrc.com/lrc/%1.lrc\n"
    "SuportPlugOfficAddres=http:/www.codecguide.com/download_kl.htm\n"
    "suportplugGetAddres=https://files2.codecguide.com/K-Lite_Codec_Pack_1848_Standard.exe\n"
"\n"
    "[BRWARG];Brower Arguments\n"
    "HeaderSkip=user-agent : Mozilla/5.0 \(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 /(KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36\n"
    "ArgImageFalseEnable=blink-settings=imagesEnabled=false\n"
    "ArgMuteAudia=--mute-audio\n"
    "ArgMaxWindow=--window-size=1920x1080\n"
    "ArgHeadless=--headless\n"
    "ArgMobileEmulation=['mobileEmulation', {'deviceName': 'iPhone 6'}]\n"
    "Arg_DevelopSetting=['excludeSwitches', ['enable-automation', 'enable-logging']]\n"
    "LocalDishLoop=True\n"
    "DriverMatchingChar=chromedriver,msedgedriver,geckodriver\n"
    "DriverMatchingChar_model=True\n"
"\n"
    "[REGEXP];Regular Expression\n"
    "MusicSearchErrorXmsj=class=\"am-alert am-alert-danger am-animation-shake\" style=\"display: block;\"(.*)</div>\n"
    "MusicAppendErrorXmsj=<span class=\"aplayer-author\">(.*)</span>\n"
    "MusicNameCountXmsj=<span class=\"aplayer-list-author\">(.*)</span>\n"
    "MusicLocationXmsj=class=\"am-btn am-btn-default\".*href=\"(http[s]?:.*?)\" download=(.*)\n"
    "MusicImageLocationXmsj=class=\"aplayer-pic\" style=\"background-image: (.*)\n"
    "MusicLrcExtractXmsj=id=\"j-lrc-btn\" class=\"am-btn am-btn-default\" target=\"_blank\" href=\"(.*?)\"\n"
    "MusicNameExtractXmsj=\\w.*[a-zA-Z].*[0-9]\n"
    "MusicNameExtractMyfree=<span class=\"aplayer-list-title\">(\\w.*?)</span>\n"
    "MusicSingerExtractMyfree=<span class=\"aplayer-list-author\">(\\w.*?)</span>\n"
    "MusicHrehExtractMyfree=class=\"btn btn-outline-secondary download\" href=\"(.*?)\"\n"
    "ImageHrehExtractMyfree=target=\"_blank\" class=\"btn btn-outline-secondary pic_download\" href=\"(.*?)\"\n"
    "MusicSearchErrorMyfree=<span>(.*?)</span>\n"
    "TimbreKey=toneFlag=LQ,toneFlag=PQ,toneFlag=HQ,toneFlag=SQ,format/LQ,format/PQ,format/HQ,format/SQ\n"
    "CopyRightMyfree=<div class=\"text-danger\">(.*?)</div>\n"
    "LyricInfoExtract = _blank\".*href=\\s?\"(?:.*\\W+(\\d+?)\\W+.*)\">(?:(.*?))<.*?.*href.*\">(.*?)<\\W+\n"
    "HyperLinkExtract=http[s]?:/.*\n"
    "AbsforSuffix=[a-zA-Z]\\s*:\\s*[\\|/].*\\..{3,%1}\n"
    "AbsHeadSuffix=[a-zA-Z]\\s*:\\s*[\\\\|/]\n"
    "Reg_Version=Version\\s+REG_SZ\\s+(.*)\n"
    "Reg_Name=DisplayName\\s+REG_SZ\\s+(.*)\n"
    "Edge_Assign_Key=Microsoft Edge\n"
    "Chrome_Assign_Key=Google Chrome\n"
    "HKEY_LOCAL_MACHINE1 = REG QUERY \"HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\"\n"
    "HKEY_LOCAL_MACHINE2 = REG QUERY \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\"\n"
    "HKEY_CURRENT_USER = REG QUERY \"HKEY_CURRENT_USER\\Software\\Google\\Chrome\\BLBeacon\"\n"
    "KLite_Decoder = REG QUERY \"HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\KLCodecPack\"\n"
    "NetVersionCompile=\\s+([\\d+\\.\\d+\\.\\d+?]+)\n"
    "FirefoxTitleCompile=align=\"left\">v(.*)[+]+ win64\n"
    "FirefoxVersionCompile=<td align=\"left\">([0-9].*)</td>\n"
"\n"
    "[VSTRANGE];Visit Range\n"
    "MusicSearchRangeXmsj=1\n"
    "MusicSearchRangeMyfree=0\n"
"\n"
    "[VSTXPATH];Visit Xpath\n"
    "NextPageXmsj=/*[@id=\"j-player\"]/div[3]/ol/li[%1]\n"
    "AuldVersionClick=/*[@id=\"app\"]/section/section/section/header/div[2]/div[1]/a\n"
    "NextPage=/*[@id=\"player\"]/div[2]\n"
    "DownLoadCheckBut=/*[@id=\"player\"]/div[1]/ol/li[%1]/span[1]\n"
    "DownLoadWinQuitClick=/*[@id=\"m-download\"]/div/div/div[3]/button\n"
"\n"
    "[DBINFO];Database Infomation\n"
    "DBNAME=undef\n"
    "DBPATH=undef\n"
    "DBSTAT=False\n"
    "MD5STAT=False\n"
"\n"
    "[LOGCFG];Diary\n"
    "LOGNAME=undef\n"
    "LOGPATH=undef\n"
    "LOGWRITE=True\n"
    "LOGPRINT=True\n"
    "LOGSTOREDAY=1\n"
    "LOGMAXSIZE=10\n"
    "LOGLEVEL[1-5]=5\n"
;

    void __CFG_WRITE__(QString PATH, QString TGL);

    void __CFG_READ__();

    void __CFG_UPDT__(QMap<QString, QString> DPDTMAP, bool IsReset=false);

    void __INIT__(bool IsReset=false, bool skipread = false);

    void __REGKEY__(QString Souce, QString Reg, QStringList &Vessel);

    void __Qss__();

    void __LOG__();

private:

    void __SQL_CREATE__();
    void __CRYPT_MD5__();
    Extend definfc;
};
#endif
